using System.Collections;

namespace CSharpPro._1023;

public class ArrayTest
{
    //整型数组，直接初始化
    private int[] arr1 = { 1, 2, 3 };
    private int[] arr4 = new int[] { 1, 2, 3 };
    //字符型数组，直接初始化
    private String[] arr2 = { "Hello", "World" };
    //整数型数组，不初始化
    private int[] arr3 = new int[3];
    
    
    //定义二维数组,并直接初始化
    private int[,] arr5 = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
    private int[,] arr7 = new int[,]{{1,2,3},{4,5,6},{7,8,9}};
    //定义二维数组，不初始化
    private int[,] arr6 = new int[2,3];

    public void TestPrint(int[] a)
    {
        //排序，从小到大
        Array.Sort(a);
        //翻转
        Array.Reverse(a);
    }
    //其他数据类型：Array,ArrayList,HashTable,Stack,Queue,
    public void TestArrayList()
    {
        ArrayList list = new ArrayList();
        list.Add(1);
        //2号索引位置插入3
        list.Insert(2,3);
        foreach (int item in list)
        {
            Console.WriteLine(item);
        }
    }

    public void TestHashTable()
    {
        Hashtable hashtable = new Hashtable();
        hashtable.Add("Key","Value");
        hashtable.Add("","");
    }
}